/*
Takes an image and displays it.  Press a button to end window.

example in terminal:

./display_pic fruits.jpg 

*/
#include "highgui.h"
#include <iostream>

using namespace std;


int main(int argc, char** argv){
	
	IplImage* img;
	
	if (argc == 1){ 						//error-checking
		img = cvLoadImage("lena.jpg", CV_LOAD_IMAGE_COLOR);	//create image object with generic image
	}else   img = cvLoadImage(argv[1], CV_LOAD_IMAGE_COLOR);	//create image object with specified image
	
	if (!img){							//error-checking
			cout <<"Error :(" ;
			exit(1);
		}
	
	cvNamedWindow( "Display Image",	CV_WINDOW_AUTOSIZE);		//create a named window
	cvShowImage("Display Image",img);				//show the image under the named window
	cvWaitKey(0);							//wait for the user to press any key
	cvReleaseImage( &img );						//done with image--clean it up
	cvDestroyWindow("Display Image");				//done with window--clean it up

}
	
